package com.cxs.service.impl;

import com.cxs.dto.NewsDTO;
import com.cxs.mapper.NewsDetailMapper;
import com.cxs.model.NewsDetail;
import com.cxs.service.NewsDetailService;
import com.cxs.vo.NewsVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
 * @Author:cxs
 * @Date:2021/10/3  11:11
 * @Version 1.0
 * @Motto:放下杂念,只为迎接明天更好的自己
 * */
@Service
public class NewsDetailServiceImpl implements NewsDetailService {

    @Autowired
    private NewsDetailMapper newsDetailMapper;

    @Override
    public PageInfo<NewsDetail> list(Integer pageNum, Integer pageSize, String keyWord) {
        PageHelper.startPage(pageNum, pageSize);
        List<NewsDetail> detailList = newsDetailMapper.selectByTitle(keyWord);
        PageInfo<NewsDetail> pageInfo = new PageInfo<>(detailList);
        return pageInfo;
    }

    @Override
    public String delete(Long id) {
        return newsDetailMapper.deleteByPrimaryKey(id) > 0 ? "删除成功" : "删除失败";
    }
}
